package com.mengniu.commerce.admin.controller.system;

import com.mengniu.commerce.admin.api.domain.SysStore;
import com.mengniu.commerce.admin.service.system.ISysStoreService;
import com.mengniu.commerce.common.core.domain.R;
import com.mengniu.commerce.common.core.utils.StringUtils;
import com.mengniu.commerce.common.core.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 店铺信息Controller
 *
 * @author FanwuZhou
 * @date 2023-11-17
 */
@RestController
@RequestMapping("/api")
public class IStoreController extends BaseController
{

    @Autowired
    private ISysStoreService sysStoreService;


    /**
     * 通过storeId获取配置,用于生成token
     */
    @GetMapping("/store/info/{storeCode}")
    public R<SysStore> info(@PathVariable("storeCode") String storeCode)
    {
        SysStore sysStore = sysStoreService.selectStoreByCode(storeCode);
        if (StringUtils.isNull(sysStore))
        {
            return R.fail("店铺不存在");
        }
        return R.ok(sysStore);
    }
}
